Skip to content

Post-merge-review: Fix template-no-empty-headings: recognize <this.X>, <@x>, <ns.X> as accessible content#2663

Merged
NullVoxPopuli merged 1 commit intoember-cli:masterfrom
johanrd:night_fix/template-no-empty-headings
Apr 13, 2026
Merged

Post-merge-review: Fix template-no-empty-headings: recognize <this.X>, <@x>, <ns.X> as accessible content#2663
NullVoxPopuli merged 1 commit intoember-cli:masterfrom
johanrd:night_fix/template-no-empty-headings

Conversation

@johanrd
Copy link
Copy Markdown
Contributor

@johanrd johanrd commented Apr 13, 2026

What's broken on master

isComponent only considers PascalCase tags or Foo::Bar nested-component syntax. It misses three valid GTS component invocation forms per the template tag format guide:

  • <this.Heading> (class-scoped component reference)
  • <@heading> (argument-passed component)
  • <ns.Heading> (dot-path re-export)

When one of these appears as the only child of a heading, the rule walks the child list, fails to identify it as a component, and reports the heading as empty.

Fix

Extend isComponent with three additional conditions: tag.startsWith('this.'), tag.startsWith('@'), tag.includes('.'). All three are component forms that cannot be HTML elements in any mode (HTML doesn't allow this./@/. in tag names).

Test plan

  • 50/50 tests pass on the branch
  • 3 new valid tests (<h1><this.Heading />, <h2><@heading />, <h3><ns.Heading />) all fail on master

Co-written by Claude.

…ldren

GTS component invocations can appear as <this.Foo>, <@foo>, or <ns.Foo>
in addition to PascalCase. The rule's isComponent() check was too narrow,
so children of headings using these forms were not recognized as content
and the heading was falsely flagged as empty.
@johanrd johanrd marked this pull request as ready for review April 13, 2026 10:29
}
const tag = node.tag;
return /^[A-Z]/.test(tag) || tag.includes('::');
// PascalCase (<MyComponent>), namespaced (<Foo::Bar>), this.-prefixed
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we couldl also have a web-component here, too -- kebab-case

@NullVoxPopuli NullVoxPopuli merged commit ef1ec73 into ember-cli:master Apr 13, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants